package com.css.zfzx.fwsjcj.modules.statistics.user.vo;

import cn.afterturn.easypoi.excel.annotation.Excel;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @Author leon
 * @Date: 2021/6/28 1:16 下午
 */
@Data
public class UserVo implements Comparable<UserVo> {
    @Excel(name = "用户名称", width = 20)
    private String userName;

    @Excel(name = "部门名称", width = 20)
    private String deptName;
    private String divisionId;

    @Excel(name = "用户地址", width = 20)
    private String divisionName;
    private String allParentId;
    private char divisionLevel;
    @Excel(name = "省", width = 20)
    private String province;
    @Excel(name = "市", width = 25)
    private String city;
    @Excel(name = "区县", width = 25)
    private String area;


    @Override
    public int compareTo(UserVo o) {
        // 省比较
        String p1 = this.province;
        String p2 = o.getProvince();
        if (StringUtils.isEmpty(p1) && StringUtils.isEmpty(p2)) {
            return 0;
        } else if (StringUtils.isEmpty(p1) && StringUtils.isNotEmpty(p2)) {
            return -1;
        } else if (StringUtils.isNotEmpty(p1) && StringUtils.isEmpty(p2)) {
            return 1;
        } else {
            int provinceFlag = p1.compareTo(p2);
            // 市比较
            if (provinceFlag == 0) {
                String c1 = this.city;
                String c2 = o.getCity();
                if (StringUtils.isEmpty(c1) && StringUtils.isEmpty(c2)) {
                    return 0;
                } else if (StringUtils.isEmpty(c1) && StringUtils.isNotEmpty(c2)) {
                    return -1;
                } else if (StringUtils.isNotEmpty(c1) && StringUtils.isEmpty(c2)) {
                    return 1;
                } else {
                    int cityFlag = c1.compareTo(c2);
                    // 县比较
                    if (cityFlag == 0) {
                        String a1 = this.area;
                        String a2 = o.getArea();
                        if (StringUtils.isNotEmpty(a1) && StringUtils.isNotEmpty(a2)) {
                            return a1.compareTo(a2);
                        }
                    }
                    return cityFlag;
                }
            }
            return provinceFlag;
        }
    }
}
